// vue-router的封装
import Vue from "vue";
import VueRouter from "vue-router";
import login from "@/views/Login.vue";
import Register from "@/views/Register.vue";
import Layout from "@/views/Layout.vue";
import My from "@/views/My.vue";
import Like from "@/views/Like.vue";
import Collect from "@/views/Collect.vue";
import Article from "@/views/Article.vue";
import Detail from "@/views/Detail.vue";

Vue.use(VueRouter);

const router = new VueRouter({
  routes: [
    // 默认到登录页  这些是一级路由
    { path: "/", redirect: "/login" },
    { path: "/login", component: login },
    { path: "/register", component: Register },
    {
      path: "/layout",
      component: Layout,
      children: [
        { path: "/layout/article", component: Article },
        { path: "/layout/collect", component: Collect },
        { path: "/layout/like", component: Like },
        { path: "/layout/my", component: My },
      ],
    },
    // 详情页
    { path: "/detail/:id", component: Detail },
  ],
  mode: "history",
  // 改类名
  linkActiveClass: "active",
  linkExactActiveClass: "ex-active",
});
/\d{6}/;
export default router;
